package magick4j;

import java.util.HashMap;
import java.util.Map;


/**
 * TODO Should this be an interface with multiple implementations or is that overkill?
 */
public class ColorDatabase {

    private static final Map<String, PixelPacket> NAMED_COLORS = buildNamedColors();

    private static Map<String, PixelPacket> buildNamedColors() {
        // TODO Maybe read from a properties file instead.
        Map<String, PixelPacket> colors = new HashMap<String, PixelPacket>();
        colors.put("aliceblue", new PixelPacket(240,248,255));
        colors.put("antiquewhite", new PixelPacket(250,235,215));
        colors.put("antiquewhite1", new PixelPacket(255,239,219));
        colors.put("antiquewhite2", new PixelPacket(238,223,204));
        colors.put("antiquewhite3", new PixelPacket(205,192,176));
        colors.put("antiquewhite4", new PixelPacket(139,131,120));
        colors.put("aqua", new PixelPacket(0,255,255));
        colors.put("aquamarine", new PixelPacket(127,255,212));
        colors.put("aquamarine1", new PixelPacket(127,255,212));
        colors.put("aquamarine2", new PixelPacket(118,238,198));
        colors.put("aquamarine3", new PixelPacket(102,205,170));
        colors.put("aquamarine4", new PixelPacket(69,139,116));
        colors.put("azure", new PixelPacket(240,255,255));
        colors.put("azure1", new PixelPacket(240,255,255));
        colors.put("azure2", new PixelPacket(224,238,238));
        colors.put("azure3", new PixelPacket(193,205,205));
        colors.put("azure4", new PixelPacket(131,139,139));
        colors.put("beige", new PixelPacket(245,245,220));
        colors.put("bisque", new PixelPacket(255,228,196));
        colors.put("bisque1", new PixelPacket(255,228,196));
        colors.put("bisque2", new PixelPacket(238,213,183));
        colors.put("bisque3", new PixelPacket(205,183,158));
        colors.put("bisque4", new PixelPacket(139,125,107));
        colors.put("black", new PixelPacket(0,0,0));
        colors.put("blanchedalmond", new PixelPacket(255,235,205));
        colors.put("blue", new PixelPacket(0,0,255));
        colors.put("blue1", new PixelPacket(0,0,255));
        colors.put("blue2", new PixelPacket(0,0,238));
        colors.put("blue3", new PixelPacket(0,0,205));
        colors.put("blue4", new PixelPacket(0,0,139));
        colors.put("blueviolet", new PixelPacket(138,43,226));
        colors.put("brown", new PixelPacket(165,42,42));
        colors.put("brown1", new PixelPacket(255,64,64));
        colors.put("brown2", new PixelPacket(238,59,59));
        colors.put("brown3", new PixelPacket(205,51,51));
        colors.put("brown4", new PixelPacket(139,35,35));
        colors.put("burlywood", new PixelPacket(222,184,135));
        colors.put("burlywood1", new PixelPacket(255,211,155));
        colors.put("burlywood2", new PixelPacket(238,197,145));
        colors.put("burlywood3", new PixelPacket(205,170,125));
        colors.put("burlywood4", new PixelPacket(139,115,85));
        colors.put("cadet blue", new PixelPacket(95,158,160));
        colors.put("cadetblue", new PixelPacket(95,158,160));
        colors.put("cadetblue1", new PixelPacket(152,245,255));
        colors.put("cadetblue2", new PixelPacket(142,229,238));
        colors.put("cadetblue3", new PixelPacket(122,197,205));
        colors.put("cadetblue4", new PixelPacket(83,134,139));
        colors.put("chartreuse", new PixelPacket(127,255,0));
        colors.put("chartreuse1", new PixelPacket(127,255,0));
        colors.put("chartreuse2", new PixelPacket(118,238,0));
        colors.put("chartreuse3", new PixelPacket(102,205,0));
        colors.put("chartreuse4", new PixelPacket(69,139,0));
        colors.put("chocolate", new PixelPacket(210,105,30));
        colors.put("chocolate1", new PixelPacket(255,127,36));
        colors.put("chocolate2", new PixelPacket(238,118,33));
        colors.put("chocolate3", new PixelPacket(205,102,29));
        colors.put("chocolate4", new PixelPacket(139,69,19));
        colors.put("coral", new PixelPacket(255,127,80));
        colors.put("coral1", new PixelPacket(255,114,86));
        colors.put("coral2", new PixelPacket(238,106,80));
        colors.put("coral3", new PixelPacket(205,91,69));
        colors.put("coral4", new PixelPacket(139,62,47));
        colors.put("cornflowerblue", new PixelPacket(100,149,237));
        colors.put("cornsilk", new PixelPacket(255,248,220));
        colors.put("cornsilk1", new PixelPacket(255,248,220));
        colors.put("cornsilk2", new PixelPacket(238,232,205));
        colors.put("cornsilk3", new PixelPacket(205,200,177));
        colors.put("cornsilk4", new PixelPacket(139,136,120));
        colors.put("crimson", new PixelPacket(220,20,60));
        colors.put("cyan", new PixelPacket(0,255,255));
        colors.put("cyan1", new PixelPacket(0,255,255));
        colors.put("cyan2", new PixelPacket(0,238,238));
        colors.put("cyan3", new PixelPacket(0,205,205));
        colors.put("cyan4", new PixelPacket(0,139,139));
        colors.put("dark violet", new PixelPacket(148,0,211));
        colors.put("darkblue", new PixelPacket(0,0,139));
        colors.put("darkcyan", new PixelPacket(0,139,139));
        colors.put("darkgoldenrod", new PixelPacket(184,134,11));
        colors.put("darkgoldenrod1", new PixelPacket(255,185,15));
        colors.put("darkgoldenrod2", new PixelPacket(238,173,14));
        colors.put("darkgoldenrod3", new PixelPacket(205,149,12));
        colors.put("darkgoldenrod4", new PixelPacket(139,101,8));
        colors.put("darkgray", new PixelPacket(169,169,169));
        colors.put("darkgreen", new PixelPacket(0,100,0));
        colors.put("darkgrey", new PixelPacket(169,169,169));
        colors.put("darkkhaki", new PixelPacket(189,183,107));
        colors.put("darkmagenta", new PixelPacket(139,0,139));
        colors.put("darkoliveGreen", new PixelPacket(85,107,47));
        colors.put("darkoliveGreen1", new PixelPacket(202,255,112));
        colors.put("darkoliveGreen2", new PixelPacket(188,238,104));
        colors.put("darkoliveGreen3", new PixelPacket(162,205,90));
        colors.put("darkoliveGreen4", new PixelPacket(110,139,61));
        colors.put("darkorange", new PixelPacket(255,140,0));
        colors.put("darkorange1", new PixelPacket(255,127,0));
        colors.put("darkorange2", new PixelPacket(238,118,0));
        colors.put("darkorange3", new PixelPacket(205,102,0));
        colors.put("darkorange4", new PixelPacket(139,69,0));
        colors.put("darkorchid", new PixelPacket(153,50,204));
        colors.put("darkorchid1", new PixelPacket(191,62,255));
        colors.put("darkorchid2", new PixelPacket(178,58,238));
        colors.put("darkorchid3", new PixelPacket(154,50,205));
        colors.put("darkorchid4", new PixelPacket(104,34,139));
        colors.put("darkred", new PixelPacket(139,0,0));
        colors.put("darksalmon", new PixelPacket(233,150,122));
        colors.put("darkseagreen", new PixelPacket(143,188,143));
        colors.put("darkseagreen1", new PixelPacket(193,255,193));
        colors.put("darkseagreen2", new PixelPacket(180,238,180));
        colors.put("darkseagreen3", new PixelPacket(155,205,155));
        colors.put("darkseagreen4", new PixelPacket(105,139,105));
        colors.put("darkslateblue", new PixelPacket(72,61,139));
        colors.put("darkslategray", new PixelPacket(47,79,79));
        colors.put("darkslategray1", new PixelPacket(151,255,255));
        colors.put("darkslategray2", new PixelPacket(141,238,238));
        colors.put("darkslategray3", new PixelPacket(121,205,205));
        colors.put("darkslategray4", new PixelPacket(82,139,139));
        colors.put("darkslategrey", new PixelPacket(47,79,79));
        colors.put("darkturquoise", new PixelPacket(0,206,209));
        colors.put("darkviolet", new PixelPacket(148,0,211));
        colors.put("deeppink", new PixelPacket(255,20,147));
        colors.put("deeppink1", new PixelPacket(255,20,147));
        colors.put("deeppink2", new PixelPacket(238,18,137));
        colors.put("deeppink3", new PixelPacket(205,16,118));
        colors.put("deeppink4", new PixelPacket(139,10,80));
        colors.put("deepskyblue", new PixelPacket(0,191,255));
        colors.put("deepskyblue1", new PixelPacket(0,191,255));
        colors.put("deepskyblue2", new PixelPacket(0,178,238));
        colors.put("deepskyblue3", new PixelPacket(0,154,205));
        colors.put("deepskyblue4", new PixelPacket(0,104,139));
        colors.put("dimgray", new PixelPacket(105,105,105));
        colors.put("dimgrey", new PixelPacket(105,105,105));
        colors.put("dodgerblue", new PixelPacket(30,144,255));
        colors.put("dodgerblue1", new PixelPacket(30,144,255));
        colors.put("dodgerblue2", new PixelPacket(28,134,238));
        colors.put("dodgerblue3", new PixelPacket(24,116,205));
        colors.put("dodgerblue4", new PixelPacket(16,78,139));
        colors.put("firebrick", new PixelPacket(178,34,34));
        colors.put("firebrick1", new PixelPacket(255,48,48));
        colors.put("firebrick2", new PixelPacket(238,44,44));
        colors.put("firebrick3", new PixelPacket(205,38,38));
        colors.put("firebrick4", new PixelPacket(139,26,26));
        colors.put("floralwhite", new PixelPacket(255,250,240));
        colors.put("forestgreen", new PixelPacket(34,139,34));
        colors.put("fractal", new PixelPacket(128,128,128));
        colors.put("freeze", new PixelPacket(0,0,0));
        colors.put("fuchsia", new PixelPacket(255,0,255));
        colors.put("gainsboro", new PixelPacket(220,220,220));
        colors.put("ghostwhite", new PixelPacket(248,248,255));
        colors.put("gold", new PixelPacket(255,215,0));
        colors.put("gold1", new PixelPacket(255,215,0));
        colors.put("gold2", new PixelPacket(238,201,0));
        colors.put("gold3", new PixelPacket(205,173,0));
        colors.put("gold4", new PixelPacket(139,117,0));
        colors.put("goldenrod", new PixelPacket(218,165,32));
        colors.put("goldenrod1", new PixelPacket(255,193,37));
        colors.put("goldenrod2", new PixelPacket(238,180,34));
        colors.put("goldenrod3", new PixelPacket(205,155,29));
        colors.put("goldenrod4", new PixelPacket(139,105,20));
        colors.put("gray", new PixelPacket(190,190,190));
        colors.put("gray", new PixelPacket(126,126,126));
        colors.put("gray0", new PixelPacket(0,0,0));
        colors.put("gray1", new PixelPacket(3,3,3));
        colors.put("gray10", new PixelPacket(26,26,26));
        colors.put("gray100", new PixelPacket(255,255,255));
        colors.put("gray100", new PixelPacket(255,255,255));
        colors.put("gray11", new PixelPacket(28,28,28));
        colors.put("gray12", new PixelPacket(31,31,31));
        colors.put("gray13", new PixelPacket(33,33,33));
        colors.put("gray14", new PixelPacket(36,36,36));
        colors.put("gray15", new PixelPacket(38,38,38));
        colors.put("gray16", new PixelPacket(41,41,41));
        colors.put("gray17", new PixelPacket(43,43,43));
        colors.put("gray18", new PixelPacket(46,46,46));
        colors.put("gray19", new PixelPacket(48,48,48));
        colors.put("gray2", new PixelPacket(5,5,5));
        colors.put("gray20", new PixelPacket(51,51,51));
        colors.put("gray21", new PixelPacket(54,54,54));
        colors.put("gray22", new PixelPacket(56,56,56));
        colors.put("gray23", new PixelPacket(59,59,59));
        colors.put("gray24", new PixelPacket(61,61,61));
        colors.put("gray25", new PixelPacket(64,64,64));
        colors.put("gray26", new PixelPacket(66,66,66));
        colors.put("gray27", new PixelPacket(69,69,69));
        colors.put("gray28", new PixelPacket(71,71,71));
        colors.put("gray29", new PixelPacket(74,74,74));
        colors.put("gray3", new PixelPacket(8,8,8));
        colors.put("gray30", new PixelPacket(77,77,77));
        colors.put("gray31", new PixelPacket(79,79,79));
        colors.put("gray32", new PixelPacket(82,82,82));
        colors.put("gray33", new PixelPacket(84,84,84));
        colors.put("gray34", new PixelPacket(87,87,87));
        colors.put("gray35", new PixelPacket(89,89,89));
        colors.put("gray36", new PixelPacket(92,92,92));
        colors.put("gray37", new PixelPacket(94,94,94));
        colors.put("gray38", new PixelPacket(97,97,97));
        colors.put("gray39", new PixelPacket(99,99,99));
        colors.put("gray4", new PixelPacket(10,10,10));
        colors.put("gray40", new PixelPacket(102,102,102));
        colors.put("gray41", new PixelPacket(105,105,105));
        colors.put("gray42", new PixelPacket(107,107,107));
        colors.put("gray43", new PixelPacket(110,110,110));
        colors.put("gray44", new PixelPacket(112,112,112));
        colors.put("gray45", new PixelPacket(115,115,115));
        colors.put("gray46", new PixelPacket(117,117,117));
        colors.put("gray47", new PixelPacket(120,120,120));
        colors.put("gray48", new PixelPacket(122,122,122));
        colors.put("gray49", new PixelPacket(125,125,125));
        colors.put("gray5", new PixelPacket(13,13,13));
        colors.put("gray50", new PixelPacket(128,128,128));
        colors.put("gray51", new PixelPacket(130,130,130));
        colors.put("gray52", new PixelPacket(133,133,133));
        colors.put("gray53", new PixelPacket(135,135,135));
        colors.put("gray54", new PixelPacket(138,138,138));
        colors.put("gray55", new PixelPacket(140,140,140));
        colors.put("gray56", new PixelPacket(143,143,143));
        colors.put("gray57", new PixelPacket(145,145,145));
        colors.put("gray58", new PixelPacket(148,148,148));
        colors.put("gray59", new PixelPacket(150,150,150));
        colors.put("gray6", new PixelPacket(15,15,15));
        colors.put("gray60", new PixelPacket(153,153,153));
        colors.put("gray61", new PixelPacket(156,156,156));
        colors.put("gray62", new PixelPacket(158,158,158));
        colors.put("gray63", new PixelPacket(161,161,161));
        colors.put("gray64", new PixelPacket(163,163,163));
        colors.put("gray65", new PixelPacket(166,166,166));
        colors.put("gray66", new PixelPacket(168,168,168));
        colors.put("gray67", new PixelPacket(171,171,171));
        colors.put("gray68", new PixelPacket(173,173,173));
        colors.put("gray69", new PixelPacket(176,176,176));
        colors.put("gray7", new PixelPacket(18,18,18));
        colors.put("gray70", new PixelPacket(179,179,179));
        colors.put("gray71", new PixelPacket(181,181,181));
        colors.put("gray72", new PixelPacket(184,184,184));
        colors.put("gray73", new PixelPacket(186,186,186));
        colors.put("gray74", new PixelPacket(189,189,189));
        colors.put("gray75", new PixelPacket(191,191,191));
        colors.put("gray76", new PixelPacket(194,194,194));
        colors.put("gray77", new PixelPacket(196,196,196));
        colors.put("gray78", new PixelPacket(199,199,199));
        colors.put("gray79", new PixelPacket(201,201,201));
        colors.put("gray8", new PixelPacket(20,20,20));
        colors.put("gray80", new PixelPacket(204,204,204));
        colors.put("gray81", new PixelPacket(207,207,207));
        colors.put("gray82", new PixelPacket(209,209,209));
        colors.put("gray83", new PixelPacket(212,212,212));
        colors.put("gray84", new PixelPacket(214,214,214));
        colors.put("gray85", new PixelPacket(217,217,217));
        colors.put("gray86", new PixelPacket(219,219,219));
        colors.put("gray87", new PixelPacket(222,222,222));
        colors.put("gray88", new PixelPacket(224,224,224));
        colors.put("gray89", new PixelPacket(227,227,227));
        colors.put("gray9", new PixelPacket(23,23,23));
        colors.put("gray90", new PixelPacket(229,229,229));
        colors.put("gray91", new PixelPacket(232,232,232));
        colors.put("gray92", new PixelPacket(235,235,235));
        colors.put("gray93", new PixelPacket(237,237,237));
        colors.put("gray94", new PixelPacket(240,240,240));
        colors.put("gray95", new PixelPacket(242,242,242));
        colors.put("gray96", new PixelPacket(245,245,245));
        colors.put("gray97", new PixelPacket(247,247,247));
        colors.put("gray98", new PixelPacket(250,250,250));
        colors.put("gray99", new PixelPacket(252,252,252));
        colors.put("green", new PixelPacket(0,128,0));
        colors.put("green", new PixelPacket(0,255,0));
        colors.put("green1", new PixelPacket(0,255,0));
        colors.put("green2", new PixelPacket(0,238,0));
        colors.put("green3", new PixelPacket(0,205,0));
        colors.put("green4", new PixelPacket(0,139,0));
        colors.put("greenyellow", new PixelPacket(173,255,47));
        colors.put("grey", new PixelPacket(190,190,190));
        colors.put("grey0", new PixelPacket(0,0,0));
        colors.put("grey1", new PixelPacket(3,3,3));
        colors.put("grey10", new PixelPacket(26,26,26));
        colors.put("grey100", new PixelPacket(255,255,255));
        colors.put("grey11", new PixelPacket(28,28,28));
        colors.put("grey12", new PixelPacket(31,31,31));
        colors.put("grey13", new PixelPacket(33,33,33));
        colors.put("grey14", new PixelPacket(36,36,36));
        colors.put("grey15", new PixelPacket(38,38,38));
        colors.put("grey16", new PixelPacket(41,41,41));
        colors.put("grey17", new PixelPacket(43,43,43));
        colors.put("grey18", new PixelPacket(46,46,46));
        colors.put("grey19", new PixelPacket(48,48,48));
        colors.put("grey2", new PixelPacket(5,5,5));
        colors.put("grey20", new PixelPacket(51,51,51));
        colors.put("grey21", new PixelPacket(54,54,54));
        colors.put("grey22", new PixelPacket(56,56,56));
        colors.put("grey23", new PixelPacket(59,59,59));
        colors.put("grey24", new PixelPacket(61,61,61));
        colors.put("grey25", new PixelPacket(64,64,64));
        colors.put("grey26", new PixelPacket(66,66,66));
        colors.put("grey27", new PixelPacket(69,69,69));
        colors.put("grey28", new PixelPacket(71,71,71));
        colors.put("grey29", new PixelPacket(74,74,74));
        colors.put("grey3", new PixelPacket(8,8,8));
        colors.put("grey30", new PixelPacket(77,77,77));
        colors.put("grey31", new PixelPacket(79,79,79));
        colors.put("grey32", new PixelPacket(82,82,82));
        colors.put("grey33", new PixelPacket(84,84,84));
        colors.put("grey34", new PixelPacket(87,87,87));
        colors.put("grey35", new PixelPacket(89,89,89));
        colors.put("grey36", new PixelPacket(92,92,92));
        colors.put("grey37", new PixelPacket(94,94,94));
        colors.put("grey38", new PixelPacket(97,97,97));
        colors.put("grey39", new PixelPacket(99,99,99));
        colors.put("grey4", new PixelPacket(10,10,10));
        colors.put("grey40", new PixelPacket(102,102,102));
        colors.put("grey41", new PixelPacket(105,105,105));
        colors.put("grey42", new PixelPacket(107,107,107));
        colors.put("grey43", new PixelPacket(110,110,110));
        colors.put("grey44", new PixelPacket(112,112,112));
        colors.put("grey45", new PixelPacket(115,115,115));
        colors.put("grey46", new PixelPacket(117,117,117));
        colors.put("grey47", new PixelPacket(120,120,120));
        colors.put("grey48", new PixelPacket(122,122,122));
        colors.put("grey49", new PixelPacket(125,125,125));
        colors.put("grey5", new PixelPacket(13,13,13));
        colors.put("grey50", new PixelPacket(128,128,128));
        colors.put("grey51", new PixelPacket(130,130,130));
        colors.put("grey52", new PixelPacket(133,133,133));
        colors.put("grey53", new PixelPacket(135,135,135));
        colors.put("grey54", new PixelPacket(138,138,138));
        colors.put("grey55", new PixelPacket(140,140,140));
        colors.put("grey56", new PixelPacket(143,143,143));
        colors.put("grey57", new PixelPacket(145,145,145));
        colors.put("grey58", new PixelPacket(148,148,148));
        colors.put("grey59", new PixelPacket(150,150,150));
        colors.put("grey6", new PixelPacket(15,15,15));
        colors.put("grey60", new PixelPacket(153,153,153));
        colors.put("grey61", new PixelPacket(156,156,156));
        colors.put("grey62", new PixelPacket(158,158,158));
        colors.put("grey63", new PixelPacket(161,161,161));
        colors.put("grey64", new PixelPacket(163,163,163));
        colors.put("grey65", new PixelPacket(166,166,166));
        colors.put("grey66", new PixelPacket(168,168,168));
        colors.put("grey67", new PixelPacket(171,171,171));
        colors.put("grey68", new PixelPacket(173,173,173));
        colors.put("grey69", new PixelPacket(176,176,176));
        colors.put("grey7", new PixelPacket(18,18,18));
        colors.put("grey70", new PixelPacket(179,179,179));
        colors.put("grey71", new PixelPacket(181,181,181));
        colors.put("grey72", new PixelPacket(184,184,184));
        colors.put("grey73", new PixelPacket(186,186,186));
        colors.put("grey74", new PixelPacket(189,189,189));
        colors.put("grey75", new PixelPacket(191,191,191));
        colors.put("grey76", new PixelPacket(194,194,194));
        colors.put("grey77", new PixelPacket(196,196,196));
        colors.put("grey78", new PixelPacket(199,199,199));
        colors.put("grey79", new PixelPacket(201,201,201));
        colors.put("grey8", new PixelPacket(20,20,20));
        colors.put("grey80", new PixelPacket(204,204,204));
        colors.put("grey81", new PixelPacket(207,207,207));
        colors.put("grey82", new PixelPacket(209,209,209));
        colors.put("grey83", new PixelPacket(212,212,212));
        colors.put("grey84", new PixelPacket(214,214,214));
        colors.put("grey85", new PixelPacket(217,217,217));
        colors.put("grey86", new PixelPacket(219,219,219));
        colors.put("grey87", new PixelPacket(222,222,222));
        colors.put("grey88", new PixelPacket(224,224,224));
        colors.put("grey89", new PixelPacket(227,227,227));
        colors.put("grey9", new PixelPacket(23,23,23));
        colors.put("grey90", new PixelPacket(229,229,229));
        colors.put("grey91", new PixelPacket(232,232,232));
        colors.put("grey92", new PixelPacket(235,235,235));
        colors.put("grey93", new PixelPacket(237,237,237));
        colors.put("grey94", new PixelPacket(240,240,240));
        colors.put("grey95", new PixelPacket(242,242,242));
        colors.put("grey96", new PixelPacket(245,245,245));
        colors.put("grey97", new PixelPacket(247,247,247));
        colors.put("grey98", new PixelPacket(250,250,250));
        colors.put("grey99", new PixelPacket(252,252,252));
        colors.put("honeydew", new PixelPacket(240,255,240));
        colors.put("honeydew1", new PixelPacket(240,255,240));
        colors.put("honeydew2", new PixelPacket(224,238,224));
        colors.put("honeydew3", new PixelPacket(193,205,193));
        colors.put("honeydew4", new PixelPacket(131,139,131));
        colors.put("hotpink", new PixelPacket(255,105,180));
        colors.put("hotpink1", new PixelPacket(255,110,180));
        colors.put("hotpink2", new PixelPacket(238,106,167));
        colors.put("hotpink3", new PixelPacket(205,96,144));
        colors.put("hotpink4", new PixelPacket(139,58,98));
        colors.put("indianRed", new PixelPacket(205,92,92));
        colors.put("indianred1", new PixelPacket(255,106,106));
        colors.put("indianred2", new PixelPacket(238,99,99));
        colors.put("indianred3", new PixelPacket(205,85,85));
        colors.put("indianred4", new PixelPacket(139,58,58));
        colors.put("indigo", new PixelPacket(75,0,130));
        colors.put("ivory", new PixelPacket(255,255,240));
        colors.put("ivory1", new PixelPacket(255,255,240));
        colors.put("ivory2", new PixelPacket(238,238,224));
        colors.put("ivory3", new PixelPacket(205,205,193));
        colors.put("ivory4", new PixelPacket(139,139,131));
        colors.put("khaki", new PixelPacket(240,230,140));
        colors.put("khaki1", new PixelPacket(255,246,143));
        colors.put("khaki2", new PixelPacket(238,230,133));
        colors.put("khaki3", new PixelPacket(205,198,115));
        colors.put("khaki4", new PixelPacket(139,134,78));
        colors.put("lavender", new PixelPacket(230,230,250));
        colors.put("lavenderblush", new PixelPacket(255,240,245));
        colors.put("lavenderblush1", new PixelPacket(255,240,245));
        colors.put("lavenderblush2", new PixelPacket(238,224,229));
        colors.put("lavenderblush3", new PixelPacket(205,193,197));
        colors.put("lavenderblush4", new PixelPacket(139,131,134));
        colors.put("lawngreen", new PixelPacket(124,252,0));
        colors.put("lemonchiffon", new PixelPacket(255,250,205));
        colors.put("lemonchiffon1", new PixelPacket(255,250,205));
        colors.put("lemonchiffon2", new PixelPacket(238,233,191));
        colors.put("lemonchiffon3", new PixelPacket(205,201,165));
        colors.put("lemonchiffon4", new PixelPacket(139,137,112));
        colors.put("lightblue", new PixelPacket(173,216,230));
        colors.put("lightblue1", new PixelPacket(191,239,255));
        colors.put("lightblue2", new PixelPacket(178,223,238));
        colors.put("lightblue3", new PixelPacket(154,192,205));
        colors.put("lightblue4", new PixelPacket(104,131,139));
        colors.put("lightcoral", new PixelPacket(240,128,128));
        colors.put("lightcyan", new PixelPacket(224,255,255));
        colors.put("lightcyan1", new PixelPacket(224,255,255));
        colors.put("lightcyan2", new PixelPacket(209,238,238));
        colors.put("lightcyan3", new PixelPacket(180,205,205));
        colors.put("lightcyan4", new PixelPacket(122,139,139));
        colors.put("lightgoldenrod", new PixelPacket(238,221,130));
        colors.put("lightgoldenrod1", new PixelPacket(255,236,139));
        colors.put("lightgoldenrod2", new PixelPacket(238,220,130));
        colors.put("lightgoldenrod3", new PixelPacket(205,190,112));
        colors.put("lightgoldenrod4", new PixelPacket(139,129,76));
        colors.put("lightgoldenrodyellow", new PixelPacket(250,250,210));
        colors.put("lightgray", new PixelPacket(211,211,211));
        colors.put("lightgreen", new PixelPacket(144,238,144));
        colors.put("lightgrey", new PixelPacket(211,211,211));
        colors.put("lightpink", new PixelPacket(255,182,193));
        colors.put("lightpink1", new PixelPacket(255,174,185));
        colors.put("lightpink2", new PixelPacket(238,162,173));
        colors.put("lightpink3", new PixelPacket(205,140,149));
        colors.put("lightpink4", new PixelPacket(139,95,101));
        colors.put("lightsalmon", new PixelPacket(255,160,122));
        colors.put("lightsalmon1", new PixelPacket(255,160,122));
        colors.put("lightsalmon2", new PixelPacket(238,149,114));
        colors.put("lightsalmon3", new PixelPacket(205,129,98));
        colors.put("lightsalmon4", new PixelPacket(139,87,66));
        colors.put("lightseagreen", new PixelPacket(32,178,170));
        colors.put("lightskyblue", new PixelPacket(135,206,250));
        colors.put("lightskyblue1", new PixelPacket(176,226,255));
        colors.put("lightskyblue2", new PixelPacket(164,211,238));
        colors.put("lightskyblue3", new PixelPacket(141,182,205));
        colors.put("lightskyblue4", new PixelPacket(96,123,139));
        colors.put("lightslateblue", new PixelPacket(132,112,255));
        colors.put("lightslategray", new PixelPacket(119,136,153));
        colors.put("lightslategrey", new PixelPacket(119,136,153));
        colors.put("lightsteelblue", new PixelPacket(176,196,222));
        colors.put("lightsteelblue1", new PixelPacket(202,225,255));
        colors.put("lightsteelblue2", new PixelPacket(188,210,238));
        colors.put("lightsteelblue3", new PixelPacket(162,181,205));
        colors.put("lightsteelblue4", new PixelPacket(110,123,139));
        colors.put("lightyellow", new PixelPacket(255,255,224));
        colors.put("lightyellow1", new PixelPacket(255,255,224));
        colors.put("lightyellow2", new PixelPacket(238,238,209));
        colors.put("lightyellow3", new PixelPacket(205,205,180));
        colors.put("lightyellow4", new PixelPacket(139,139,122));
        colors.put("lime", new PixelPacket(0,255,0));
        colors.put("limegreen", new PixelPacket(50,205,50));
        colors.put("linen", new PixelPacket(250,240,230));
        colors.put("magenta", new PixelPacket(255,0,255));
        colors.put("magenta1", new PixelPacket(255,0,255));
        colors.put("magenta2", new PixelPacket(238,0,238));
        colors.put("magenta3", new PixelPacket(205,0,205));
        colors.put("magenta4", new PixelPacket(139,0,139));
        colors.put("maroon", new PixelPacket(128,0,0));
        colors.put("maroon", new PixelPacket(176,48,96));
        colors.put("maroon1", new PixelPacket(255,52,179));
        colors.put("maroon2", new PixelPacket(238,48,167));
        colors.put("maroon3", new PixelPacket(205,41,144));
        colors.put("maroon4", new PixelPacket(139,28,98));
        colors.put("matte", new PixelPacket(0,0,0));
        colors.put("mediumaquamarine", new PixelPacket(102,205,170));
        colors.put("mediumblue", new PixelPacket(0,0,205));
        colors.put("mediumforestgreen", new PixelPacket(50,129,75));
        colors.put("mediumgoldenrod", new PixelPacket(209,193,102));
        colors.put("mediumorchid", new PixelPacket(186,85,211));
        colors.put("mediumorchid1", new PixelPacket(224,102,255));
        colors.put("mediumorchid2", new PixelPacket(209,95,238));
        colors.put("mediumorchid3", new PixelPacket(180,82,205));
        colors.put("mediumorchid4", new PixelPacket(122,55,139));
        colors.put("mediumpurple", new PixelPacket(147,112,219));
        colors.put("mediumpurple1", new PixelPacket(171,130,255));
        colors.put("mediumpurple2", new PixelPacket(159,121,238));
        colors.put("mediumpurple3", new PixelPacket(137,104,205));
        colors.put("mediumpurple4", new PixelPacket(93,71,139));
        colors.put("mediumseagreen", new PixelPacket(60,179,113));
        colors.put("mediumslateblue", new PixelPacket(123,104,238));
        colors.put("mediumspringgreen", new PixelPacket(0,250,154));
        colors.put("mediumturquoise", new PixelPacket(72,209,204));
        colors.put("mediumvioletred", new PixelPacket(199,21,133));
        colors.put("midnightblue", new PixelPacket(25,25,112));
        colors.put("mintcream", new PixelPacket(245,255,250));
        colors.put("mistyrose", new PixelPacket(255,228,225));
        colors.put("mistyrose1", new PixelPacket(255,228,225));
        colors.put("mistyrose2", new PixelPacket(238,213,210));
        colors.put("mistyrose3", new PixelPacket(205,183,181));
        colors.put("mistyrose4", new PixelPacket(139,125,123));
        colors.put("moccasin", new PixelPacket(255,228,181));
        colors.put("navajowhite", new PixelPacket(255,222,173));
        colors.put("navajowhite1", new PixelPacket(255,222,173));
        colors.put("navajowhite2", new PixelPacket(238,207,161));
        colors.put("navajowhite3", new PixelPacket(205,179,139));
        colors.put("navajowhite4", new PixelPacket(139,121,94));
        colors.put("navy", new PixelPacket(0,0,128));
        colors.put("navyblue", new PixelPacket(0,0,128));
        colors.put("none", new PixelPacket(0,0,0));
        colors.put("oldlace", new PixelPacket(253,245,230));
        colors.put("olive", new PixelPacket(128,128,0));
        colors.put("olivedrab", new PixelPacket(107,142,35));
        colors.put("olivedrab1", new PixelPacket(192,255,62));
        colors.put("olivedrab2", new PixelPacket(179,238,58));
        colors.put("olivedrab3", new PixelPacket(154,205,50));
        colors.put("olivedrab4", new PixelPacket(105,139,34));
        colors.put("opaque", new PixelPacket(0,0,0));
        colors.put("orange", new PixelPacket(255,165,0));
        colors.put("orange1", new PixelPacket(255,165,0));
        colors.put("orange2", new PixelPacket(238,154,0));
        colors.put("orange3", new PixelPacket(205,133,0));
        colors.put("orange4", new PixelPacket(139,90,0));
        colors.put("orangered", new PixelPacket(255,69,0));
        colors.put("orangered1", new PixelPacket(255,69,0));
        colors.put("orangered2", new PixelPacket(238,64,0));
        colors.put("orangered3", new PixelPacket(205,55,0));
        colors.put("orangered4", new PixelPacket(139,37,0));
        colors.put("orchid", new PixelPacket(218,112,214));
        colors.put("orchid1", new PixelPacket(255,131,250));
        colors.put("orchid2", new PixelPacket(238,122,233));
        colors.put("orchid3", new PixelPacket(205,105,201));
        colors.put("orchid4", new PixelPacket(139,71,137));
        colors.put("palegoldenrod", new PixelPacket(238,232,170));
        colors.put("palegreen", new PixelPacket(152,251,152));
        colors.put("palegreen1", new PixelPacket(154,255,154));
        colors.put("palegreen2", new PixelPacket(144,238,144));
        colors.put("palegreen3", new PixelPacket(124,205,124));
        colors.put("palegreen4", new PixelPacket(84,139,84));
        colors.put("paleturquoise", new PixelPacket(175,238,238));
        colors.put("paleturquoise1", new PixelPacket(187,255,255));
        colors.put("paleturquoise2", new PixelPacket(174,238,238));
        colors.put("paleturquoise3", new PixelPacket(150,205,205));
        colors.put("paleturquoise4", new PixelPacket(102,139,139));
        colors.put("palevioletRed", new PixelPacket(219,112,147));
        colors.put("palevioletRed1", new PixelPacket(255,130,171));
        colors.put("palevioletRed2", new PixelPacket(238,121,159));
        colors.put("palevioletRed3", new PixelPacket(205,104,137));
        colors.put("palevioletRed4", new PixelPacket(139,71,93));
        colors.put("papayawhip", new PixelPacket(255,239,213));
        colors.put("peachpuff", new PixelPacket(255,218,185));
        colors.put("peachpuff1", new PixelPacket(255,218,185));
        colors.put("peacgpuff2", new PixelPacket(238,203,173));
        colors.put("peachpuff3", new PixelPacket(205,175,149));
        colors.put("peachpuff4", new PixelPacket(139,119,101));
        colors.put("peru", new PixelPacket(205,133,63));
        colors.put("pink", new PixelPacket(255,192,203));
        colors.put("pink1", new PixelPacket(255,181,197));
        colors.put("pink2", new PixelPacket(238,169,184));
        colors.put("pink3", new PixelPacket(205,145,158));
        colors.put("pink4", new PixelPacket(139,99,108));
        colors.put("plum", new PixelPacket(221,160,221));
        colors.put("plum1", new PixelPacket(255,187,255));
        colors.put("plum2", new PixelPacket(238,174,238));
        colors.put("plum3", new PixelPacket(205,150,205));
        colors.put("plum4", new PixelPacket(139,102,139));
        colors.put("powderblue", new PixelPacket(176,224,230));
        colors.put("purple", new PixelPacket(160,32,240));
        colors.put("purple", new PixelPacket(128,0,128));
        colors.put("purple1", new PixelPacket(155,48,255));
        colors.put("purple2", new PixelPacket(145,44,238));
        colors.put("purple3", new PixelPacket(125,38,205));
        colors.put("purple4", new PixelPacket(85,26,139));
        colors.put("red", new PixelPacket(255,0,0));
        colors.put("red1", new PixelPacket(255,0,0));
        colors.put("red2", new PixelPacket(238,0,0));
        colors.put("red3", new PixelPacket(205,0,0));
        colors.put("red4", new PixelPacket(139,0,0));
        colors.put("rosybrown", new PixelPacket(188,143,143));
        colors.put("rosybrown1", new PixelPacket(255,193,193));
        colors.put("rosybrown2", new PixelPacket(238,180,180));
        colors.put("rosybrown3", new PixelPacket(205,155,155));
        colors.put("rosybrown4", new PixelPacket(139,105,105));
        colors.put("royalblue", new PixelPacket(65,105,225));
        colors.put("royalblue1", new PixelPacket(72,118,255));
        colors.put("royalblue2", new PixelPacket(67,110,238));
        colors.put("royalblue3", new PixelPacket(58,95,205));
        colors.put("royalblue4", new PixelPacket(39,64,139));
        colors.put("saddlebrown", new PixelPacket(139,69,19));
        colors.put("salmon", new PixelPacket(250,128,114));
        colors.put("salmon1", new PixelPacket(255,140,105));
        colors.put("salmon2", new PixelPacket(238,130,98));
        colors.put("salmon3", new PixelPacket(205,112,84));
        colors.put("salmon4", new PixelPacket(139,76,57));
        colors.put("sandybrown", new PixelPacket(244,164,96));
        colors.put("seagreen", new PixelPacket(46,139,87));
        colors.put("seagreen1", new PixelPacket(84,255,159));
        colors.put("seagreen2", new PixelPacket(78,238,148));
        colors.put("seagreen3", new PixelPacket(67,205,128));
        colors.put("seagreen4", new PixelPacket(46,139,87));
        colors.put("seashell", new PixelPacket(255,245,238));
        colors.put("seashell1", new PixelPacket(255,245,238));
        colors.put("seashell2", new PixelPacket(238,229,222));
        colors.put("seashell3", new PixelPacket(205,197,191));
        colors.put("seashell4", new PixelPacket(139,134,130));
        colors.put("sienna", new PixelPacket(160,82,45));
        colors.put("sienna1", new PixelPacket(255,130,71));
        colors.put("sienna2", new PixelPacket(238,121,66));
        colors.put("sienna3", new PixelPacket(205,104,57));
        colors.put("sienna4", new PixelPacket(139,71,38));
        colors.put("silver", new PixelPacket(192,192,192));
        colors.put("skyblue", new PixelPacket(135,206,235));
        colors.put("skyblue1", new PixelPacket(135,206,255));
        colors.put("skyblue2", new PixelPacket(126,192,238));
        colors.put("skyblue3", new PixelPacket(108,166,205));
        colors.put("skyblue4", new PixelPacket(74,112,139));
        colors.put("slateblue", new PixelPacket(106,90,205));
        colors.put("slateblue1", new PixelPacket(131,111,255));
        colors.put("slateblue2", new PixelPacket(122,103,238));
        colors.put("slateblue3", new PixelPacket(105,89,205));
        colors.put("slateblue4", new PixelPacket(71,60,139));
        colors.put("slategray", new PixelPacket(112,128,144));
        colors.put("slategray1", new PixelPacket(198,226,255));
        colors.put("slategray2", new PixelPacket(185,211,238));
        colors.put("slategray3", new PixelPacket(159,182,205));
        colors.put("slategray4", new PixelPacket(108,123,139));
        colors.put("slategrey", new PixelPacket(112,128,144));
        colors.put("snow", new PixelPacket(255,250,250));
        colors.put("snow1", new PixelPacket(255,250,250));
        colors.put("snow2", new PixelPacket(238,233,233));
        colors.put("snow3", new PixelPacket(205,201,201));
        colors.put("snow4", new PixelPacket(139,137,137));
        colors.put("springgreen", new PixelPacket(0,255,127));
        colors.put("springgreen1", new PixelPacket(0,255,127));
        colors.put("springgreen2", new PixelPacket(0,238,118));
        colors.put("springgreen3", new PixelPacket(0,205,102));
        colors.put("springgreen4", new PixelPacket(0,139,69));
        colors.put("steelblue", new PixelPacket(70,130,180));
        colors.put("steelblue1", new PixelPacket(99,184,255));
        colors.put("steelblue2", new PixelPacket(92,172,238));
        colors.put("steelblue3", new PixelPacket(79,148,205));
        colors.put("steelblue4", new PixelPacket(54,100,139));
        colors.put("tan", new PixelPacket(210,180,140));
        colors.put("tan1", new PixelPacket(255,165,79));
        colors.put("tan2", new PixelPacket(238,154,73));
        colors.put("tan3", new PixelPacket(205,133,63));
        colors.put("tan4", new PixelPacket(139,90,43));
        colors.put("teal", new PixelPacket(0,128,128));
        colors.put("thistle", new PixelPacket(216,191,216));
        colors.put("thistle1", new PixelPacket(255,225,255));
        colors.put("thistle2", new PixelPacket(238,210,238));
        colors.put("thistle3", new PixelPacket(205,181,205));
        colors.put("thistle4", new PixelPacket(139,123,139));
        colors.put("tomato", new PixelPacket(255,99,71));
        colors.put("tomato1", new PixelPacket(255,99,71));
        colors.put("tomato2", new PixelPacket(238,92,66));
        colors.put("tomato3", new PixelPacket(205,79,57));
        colors.put("tomato4", new PixelPacket(139,54,38));
        colors.put("transparent", new PixelPacket(0,0,0));
        colors.put("turquoise", new PixelPacket(64,224,208));
        colors.put("turquoise1", new PixelPacket(0,245,255));
        colors.put("turquoise2", new PixelPacket(0,229,238));
        colors.put("turquoise3", new PixelPacket(0,197,205));
        colors.put("turquoise4", new PixelPacket(0,134,139));
        colors.put("violet", new PixelPacket(238,130,238));
        colors.put("violetred", new PixelPacket(208,32,144));
        colors.put("violetred1", new PixelPacket(255,62,150));
        colors.put("violetred2", new PixelPacket(238,58,140));
        colors.put("violetred3", new PixelPacket(205,50,120));
        colors.put("violetred4", new PixelPacket(139,34,82));
        colors.put("wheat", new PixelPacket(245,222,179));
        colors.put("wheat1", new PixelPacket(255,231,186));
        colors.put("wheat2", new PixelPacket(238,216,174));
        colors.put("wheat3", new PixelPacket(205,186,150));
        colors.put("wheat4", new PixelPacket(139,126,102));
        colors.put("white", new PixelPacket(255,255,255));
        colors.put("whitesmoke", new PixelPacket(245,245,245));
        colors.put("yellow", new PixelPacket(255,255,0));
        colors.put("yellow1", new PixelPacket(255,255,0));
        colors.put("yellow2", new PixelPacket(238,238,0));
        colors.put("yellow3", new PixelPacket(205,205,0));
        colors.put("yellow4", new PixelPacket(139,139,0));
        colors.put("yellowgreen", new PixelPacket(154,205,50));
        return colors;
    }

    static String getName(PixelPacket pixel) {
        if(NAMED_COLORS.containsValue(pixel)){
            for(String key : NAMED_COLORS.keySet()){
                if(NAMED_COLORS.get(key).equals(pixel))
                    return key;
            }
        }
        return null;
    }
    
    public static PixelPacket queryDefault(String colorName) {
        return new ColorDatabase().query(colorName);
    }

    public static PixelPacket lookUp(String colorName) {
        // TODO Make PixelPacket cloneable and store PixelPackets in NAMED_COLORS instead of Strings?
        // TODO Should "#rrggbb" also support alpha at the end?
        if (colorName.equals("transparent") || colorName.equals("none")) {
            return new PixelPacket(0, 0, 0, 255);
        }
        String oldName = colorName;
        PixelPacket color = NAMED_COLORS.get(colorName.toLowerCase());
        if (color == null) {
            System.err.println("not found: " + oldName);
        }
        return colorName == null ? null : color;
    }

    private PixelPacket parseRgb(String rgb) {
        // TODO Fix it
        if (rgb.length() == 6) {
            // If NumberFormatException, that's okay. Crazy input.
            // Just need to be able to say this in Ruby:
            // ArgumentError: invalid color name: #eerr00
            int red = Integer.parseInt(rgb.substring(0, 2), 16);
            int green = Integer.parseInt(rgb.substring(2, 4), 16);
            int blue = Integer.parseInt(rgb.substring(4, 6), 16);
            return new PixelPacket(red, green, blue);
        } else if(rgb.length() == 3){
            int red = Integer.parseInt(rgb.substring(0, 1)+rgb.substring(0, 1), 16);
            int green = Integer.parseInt(rgb.substring(1, 2)+rgb.substring(1, 2), 16);
            int blue = Integer.parseInt(rgb.substring(2, 3)+rgb.substring(2, 3), 16);
            return new PixelPacket(red, green, blue);
        }
        return null;
    }

    public PixelPacket query(String colorName) {
        if (colorName.startsWith("#")) {
            return parseRgb(colorName.substring(1));
        } else {
            return lookUp(colorName);
        }
    }
}
